<template>
    <view>
        <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
            <swiper-item v v-for="(item, i) in swiperList" :key="i">
                <view class="swiper-item">
                    <image :src="item.image_src" mode=""></image>
                </view>
            </swiper-item>
        </swiper>
        <!-- <view class="btn_settle" @click="test">test</view> -->
        <view>{{token}}</view>
    </view>
</template>

<script>
    import {
        mapState,
        mapMutations
    } from 'vuex'

    export default {

        computed: {
            ...mapState('m_user', ['token'])
        },

        data() {
            return {
                // 轮播图
                swiperList: []
            };
        },
        onLoad() {
            // this.getSwiperList()
            // this.addToken('123456')
        },

        methods: {

            ...mapMutations('m_user', ['addToken']),

            async getSwiperList() {
                const res = await uni.$http.post('/api/public/v1/home/swiperdata')
                console.log(res)

                if (res.data.meta.status !== 200) {
                    return uni.$showMsg()
                }
                this.swiperList = res.data.message
                console.log(this.swiperList)
            },

            test() {

            }
        }
    }
</script>

<style lang="scss">
    swiper {
        height: 330rpx;

        .swiper-item,
        image {
            width: 100%;
            height: 100%;
        }
    }
</style>